    
            <section class="row">
                <div class="col-lg-12">
                    <div>
                        <h1><i class="fa fa-dashboard"></i> <?= $template['title'] ?></h1>
                    </div>
                    <div>
                        <?= $this->breadcrumb->output(); ?>
                    </div>
                </div>
            </section>

        <div id="ajax-container">
            <?php if(isset($template['partials']['notifications'])) echo $template['partials']['notifications']; ?>
            
            <?php foreach($permissions as $permission) : ?>
                <section class="row">
                    <div class="col-12">
                        <div class="panel panel-default tab-container">
                            <div class="panel-heading">
                                <h2 class="panel-title"><i class="glyphicon glyphicon-folder-close"></i> <?= $permission['company']['name'] ?></h2>
                            </div>
                            <div class="panel-body tabs no-padding tabs-left">

                                <div class="guideline guideline-sticky bg-info">
                                    <i class="fa fa-info-circle fa-lg"></i> Panel Guideline Goes Here.
                                </div>
                                <ul class="nav nav-tabs">
                                    <?php
                                        foreach($permission['roles'] as $role)
                                        {
                                            $active = $role === end($permission['roles']) ? ' class="active"' : '';
                                            echo "<li{$active}><a href='#{$permission['company']['name']}-{$role['id']}' data-toggle='tab'><i class='fa fa-group'></i> <span class='hidden-xs'>{$role['name']}</span></a></li>\n";
                                        }
                                    ?>
                                </ul>
                                <div class="tab-content media-body">
                                    <?php
                                        foreach($permission['roles'] as $role) :
                                        $active = $role === end($permission['roles']) ? ' active' : '';
                                    ?>
                                    <div id="<?= $permission['company']['name'] .'-'. $role['id'] ?>" class="tab-pane<?= $active ?>">

                                        <form action="<?= base_url() ?>permissions/update" method="post">
                                            <input type="hidden" name="company_id" value="<?= $permission['company']['id'] ?>" />
                                            <input type="hidden" name="group_id" value="<?= $role['id'] ?>" />
                                            <table class="table table-hover table-bordered table-responsive">
                                                <caption><?= $role['name'] ?></caption>
                                                <thead>
                                                    <tr>
                                                        <th class="align-center script_show"><input type="checkbox" name="toggle_all" id="toggle_all" class="toggle"></th>
                                                        <th>Module Name</th>
                                                        <?php foreach($permission['permission_set'] as $permission_title) : ?>
                                                        <th class="align-center"><?= $permission_title ?></th>
                                                        <?php endforeach ; ?>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <?php
                                                        foreach($permission['modules'] as $module) :
                                                        $module_name            = isset($module['name']) ? strtolower( str_replace(' ', '_', $module['name']) ) : '';
                                                        $module_permissions     = isset($module['permissions']) ? unserialize($module['permissions']) : '';
                                                    ?>
                                                    <tr>
                                                        <td class="align-center script_show"><input type="checkbox" name="<?= $module_name ?>" id="<?= $module_name ?>" class="toggle toggle-all"></td>
                                                        <td><label for="<?= $module_name ?>"><?= $module['name'] ?></label></td>
                                                        <?php
                                                            foreach($permission['permission_set'] as $perm)
                                                            {
                                                                $perm                       = changeCase( $perm, 'human_upper' );
                                                                $module_permission          = in_array($perm, $module_permissions) ? $perm : 'N/A';
//                                                                $role_id                    = isset( $permission['permissions'][$role['id']][$module['id']]['id'] ) ? $permission['permissions'][$role['id']][$module['id']]['id'] : '';
                                                                $role_module_permissions    = isset( $permission['permissions'][$permission['company']['id']][$role['id']][$module['id']]['group_permissions'] ) ? unserialize($permission['permissions'][$permission['company']['id']][$role['id']][$module['id']]['group_permissions']) : array();
                                                                $checked                    = isset($role_module_permissions[$perm]) && ($role_module_permissions[$perm] == 1) ? ' checked="checked"' : '';

                                                                echo '<td class="align-center">';
                                                                echo $module_permission === 'N/A' ? 'N/A' : "<input type='checkbox' name='permissions[{$permission['company']['id']}-{$role['id']}-{$module['id']}][{$perm}]' class='toggle-all {$module_name}' value='1'{$checked}>";
                                                                echo '</td>';
                                                            }
                                                        ?>
                                                    <?php endforeach; ?>
                                                </tbody>
                                            </table>

                                            <div class="table-pagination">
                                                <button type="submit" class="btn btn-primary">Save</button>
                                                <button type="button" class="btn">Reset</button>
                                            </div>
                                        </form>

                                    </div>
                                    <?php endforeach; ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>
            <?php endforeach; ?>
            
            <!-- page-script -->
            <script src="<?= base_url() ?>js/modules/modules.js"></script>
        </div>